<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/sc/js/page.js"></script>
    <style>
        .quxiao{color:red;text-decoration: line-through;}
        .is_yd{color:blue;text-decoration: line-through;}
    </style>
</head>

<body style="color:#333;">
<!-- 标题 -->
<div class="page-heade clearfix">

    <h2 class="title_color text-center"  href="{:url('TiFeiyong/index')}">TI费用申请</h2>
    <!--<h2 class="clearfix text-center">
        <a class="col-md-3 title_color H_right H_active" id="Ap1" style="font-size: 16px"
           href="{:url('ti_apply/index')}">常规促销费用申请</a>
        <a class="col-md-3 title_color H_right" id="Ap2" style="color:#333;font-size: 16px" href="{:url('TiApply2/index')}">非常规促销费用申请</a>
        <a class="col-md-3 title_color H_right" id="Ap3" style="color:#333;font-size: 16px" href="{:url('Tijinchang/index')}">进场费用申请</a>
        <a class="col-md-3 title_color" id="Ap4" style="color:#333;font-size: 16px" href="{:url('other/zxfeiyongapply')}">专项费用申请</a>
    </h2>-->
</div>
<!-- 标题 -->
<div class="form-inline">
    <form action="#" method="post" id="form_check" class="formpage">
        <input type="hidden" value='{$page}' name="page" id="page-go"/>
        <input type="hidden" value='{$list}' name="list" id="list-go"/>
        <table class="row-margin-top tab-content table-bordered table text-center" border="1">
            <tr>
                <td class="text-left" colspan="6"><a href="{:url('TiFeiyong/addInfoHtml')}" class="btn btn-sm btn-info">新增TI费用申请</a></td>
            </tr>
            <tr>
                <td style="width: 120px" class="text-right">活动编号：</td>
                <td>
                    <input type="text" name="no" value="{$data.no}" class="form-control" placeholder="请输入活动编号" style="width: 300px">
                </td>
                <td style="width: 120px" class="text-right">活动主题：</td>
                <td>
                    <input type="text" name="title" value="{$data.title}" class="form-control" placeholder="请输入活动主题">
                </td>
                <td style="width: 120px" class="text-right">状态：</td>
                <td>
                    <select  name="status" id="state" class="form-control select">
                        <option value="0">请选择</option>
                        <option value="1" {if isset($data.status)&&$data.status==1}selected{/if}>草稿</option>
                        <option value="2" {if isset($data.status)&&$data.status==2}selected{/if}>已打回</option>
                        <option value="3" {if isset($data.status)&&$data.status==3}selected{/if}>区域领导审批</option>
                        <option value="4" {if isset($data.status)&&$data.status==4}selected{/if}>拆分人审批</option>
                        <option value="5" {if isset($data.status)&&$data.status==5}selected{/if}>集团领导审批</option>
                        <option value="6" {if isset($data.status)&&$data.status==6}selected{/if}>抄送</option>
                        <option value="7" {if isset($data.status)&&$data.status==7}selected{/if}>已归档</option>
                        <option value="8" {if isset($data.status)&&$data.status==8}selected{/if}>已作废</option>
                        <option value="9" {if isset($data.status)&&$data.status==9}selected{/if}>已否决</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 120px" class="text-right">申请时间：</td>
                <td>
                    <div class="form-group">
                        <input type="text" id="start" placeholder="开始日期" class="form-control layer-date "
                               style="min-width:100px;height: 26px;display: inline-block;" name="start" value="{$data.start}">
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" placeholder="结束日期"
                               style="min-width:100px;height: 26px;display: inline-block;" id="end" name="end" value="{$data.end}">
                    </div>
                </td>

                <td style="width: 120px" class="text-right">经销商名：</td>
                <td>
                    <input type="text" name="jxs" class="form-control" value="{$data.jxs}" placeholder="请输入经销商名">
                </td>
                <td colspan="2" class="text-center">
                    <button class="btn-sm btn-info btn" id="check">查询</button><span class="lr_5"></span>
                    <button class="btn-sm btn-info btn" type="reset" id="clear_check">清空查询条件</button>
                </td>
            </tr>


        </table>

        <table class="table table-striped table-bordered table-hover bud_hei text-center">
            <tr class="info text-center">
                <!--<th class="text-center">NO.</th>
                <th class="text-center">类型</th>
                <th class="text-center">编号</th>
                <th class="text-center">主题</th>
                <th class="text-center">状态</th>
                <th class="text-center">申请人</th>
                <th class="text-center">申请时间</th>
                <th class="text-center">操作</th>-->
                <th class="text-center">No.</th>
                <th class="text-center">编号</th>
                <th class="text-center" style="width: 400px">主题</th>
                <th class="text-center">经销商名</th>
                <th class="text-center">状态</th>
                <th class="text-center">申请人</th>
                <th class="text-center">申请时间</th>
                <th class="text-center">操作</th>
            </tr>
            {volist name="applys" id="vo"}
            <tr>
                <td>{$i}</td>
                <td><a href="{:url('other/freedetail')}"> {$vo.sn}</a></td>
                <td class="text-left font-bold">
                    {if condition="$vo.status2 eq 2"}
                    <span class='quxiao'>
                    {elseif condition="$vo.status2 eq 1"}
                         <span class='is_yd'>
                    {else/}
                        <span>
                    {/if}
                    {$vo.title}
                          {if condition="$vo.status2 eq 2"}
                            <span class="glyphicon glyphicon-remove yidong" title="已取消" aria-hidden="true"></span>
                         {/if}
                        {if condition="$vo.status2 eq 1"}
                             <span class="glyphicon glyphicon-remove yidong " title="已异动" aria-hidden="true"></span>
                         {/if}
                         {if condition="$vo.status eq 7 and $vo.status2 eq ''"}
                            <span class="glyphicon glyphicon-ok duigou" title="已生效" aria-hidden="true"></span>
                         {/if}
                         {if $vo.fb==1}
                        <span class="glyphicon glyphicon-send fankui" title="已反馈" aria-hidden="true"></span>
                        {/if}
                        {if $vo.yihe==1}
                        <span class="glyphicon glyphicon-yen yen" title="已核销" aria-hidden="true"></span>
                        {/if}
                        </span>

                            <!--<span class="glyphicon glyphicon-ok duigou" title="已生效" aria-hidden="true"></span>--></td>
                <td class="text-left"> {$vo.jxs}</td>
                <td>{$vo.status_type}</td>
                <td>{$vo.cname}</td>
                <td>{$vo.ctime}</td>
                <td>


                    <!--{if condition="$vo.status eq 1"}
                    <a onclick="gostate(3,{$vo.id})">提交工作流</a>
                    {if $vo.cate_id==1}
                    <a href="{:url('addInfoHtml')}?aid={$vo.id}">修改</a>
                    {/if}
                    <a onclick="shanchu({$vo.id})">删除</a>
                    {else/}

                    {if condition="$vo.status eq 2"}
                    {if $vo.cate_id==1}
                    <a href="{:url('addInfoHtml')}?aid={$vo.id}">修改/作废</a>
                    {elseif $vo.cate_id==2}
                    <a href="{:url('Workflowdb/ydshenhe')}?aid={$vo.id}&from=2">作废</a>
                    {else}
                    <a href="{:url('Workflowdb/qxshenhe')}?aid={$vo.id}&from=2">作废</a>
                    {/if}
                    {/if}

                    {if condition="$vo.status2 eq 0 and $vo.cate_id neq 3"}
                    {if condition="$vo.fb eq 0 and $vo.is_ydqx eq 0"}

                    <a onclick="yidong({$vo.id})">异动a</a>
                    <a onclick="quxiao({$vo.id})">取消b</a>
                    {/if}

                    {if condition="$vo.is_ydqx eq 0"}
                    {if condition="$vo.kefan eq 1"}
                    <a href="javascript:;" class="feedback" aid="{$vo.id}" aname="{$vo.khtype}">反馈1</a>
                    {/if}
                    //<a href="{:url('TiFeiyong/hexiao')}?aid={$vo.id}" class="J_menuItem">核销2</a>
                    <a href="{:url('TiFeiyong/hexiao')}?aid={$vo.id}" class="J_menuItem">核销2</a>

                    {/if}

                    {/if}

                    <a class="J_menuItem" href="{:url('workflowchart',['id'=>$vo.id])}">流程图3</a>
                    {/if}-->

                    {if condition="$vo.status eq 1"}
                    <a onclick="gostate(3,{$vo.id})">提交1工作流</a>
                    {if $vo.cate_id==1}
                    <a href="{:url('addInfoHtml')}?aid={$vo.id}">修改</a>
                    {/if}
                    <a onclick="shanchu({$vo.id})">删除</a>
                    {else/}

                    {if condition="$vo.status eq 2"}
                    {if $vo.cate_id==1}
                    <a href="{:url('addInfoHtml')}?aid={$vo.id}">修改/作废</a>
                    {elseif $vo.cate_id==2}
                    <a href="{:url('Workflowdb/ydshenhe')}?aid={$vo.id}&from=2">作废</a>
                    {else}
                    <a href="{:url('Workflowdb/qxshenhe')}?aid={$vo.id}&from=2">作废</a>
                    {/if}
                    {/if}
                    {if condition="$vo.status eq 7"}
                    {if condition="$vo.status2 eq 0 and $vo.cate_id neq 3"}
                    {if condition="$vo.fb eq 0 and $vo.is_ydqx eq 0"}
                    <a onclick="yidong({$vo.id})">异动</a>
                    <a onclick="quxiao({$vo.id})">取消</a>
                    {/if}
                    {if condition="$vo.is_ydqx eq 0"}
                    {if condition="$vo.kefan eq 1"}
                    <a class="feedback" aid='{$vo.id}'>反馈</a>
                    {/if}

                    <a href="{:url('TiFeiyong/hexiao')}?aid={$vo.id}" class="J_menuItem">核销</a>
                    {/if}

                    {/if}

                    {/if}



                    <a class="J_menuItem" href="{:url('workflowchart',['id'=>$vo.id])}">流程图</a>
                    {/if}

                </td>
            </tr>

                </td>
            </tr>

            {/volist}
        </table>
        <h5 class="text-center" id="pagesc" style="font-size: 16px;font-weight: 500">
            <script>
                $(function(){
                    pageSC("pagesc",{$sum},{$page},{$maxpage})
                })
            </script>
            每页显示
            <select id="pagesize">
                <option value='20' {if condition="$list eq 20"}selected{/if}>20条</option>
                <option value='40'{if condition="$list eq 40"}selected{/if}>40条</option>
                <option value='50'{if condition="$list eq 50"}selected{/if}>50条</option>

            </select>
        </h5>
    </form>
</div>
<!-- 全局js -->
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!--统计代码，可删除-->
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<script>
    //详情也
    function xiangqing(aid){
        var index = layer.open({
            type:2,
            title:'常规促销申请',
            area:['100%','100%'],
            maxmin:true,
            content:'{:url("apply_de")}?aid='+aid
        })
    }
    function shenhe(apid){
        swal({
            title: "提示",
            text: "您真的要审核这个申请么？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#33FF33",
            confirmButtonText: "是的我要审核",
            cancelButtonText: "取消",
            closeOnConfirm: true
        }, function (isConfirm) {
            if (isConfirm) {
                $.post("{:url('TiFeiyong/shapply')}",{aid:apid},function(re){
                    //alert(re);
                    if(re==1){
                        swal({
                            title: "完成",
                            text: "成功审核申请",
                            type: "success"

                        },function(){
                            document.getElementById("form_check").submit();
                        })
                    }else{
                        swal({
                            title: "错误",
                            text: "系统繁忙请稍后再试",
                            type: "warning"
                        });
                    }

                })
            }
        })
    }
    function shanchuqx(apid){
        swal({
                title: "提示",
                text: "您真的要删除这个申请么？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#FF3333",
                confirmButtonText: "是的我要删除",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function (isConfirm) {
                if (isConfirm) {
                    $.post("{:url('TiFeiyong/shanchuqx')}",{aid:apid},function(re){
                        // alert(re);
                        var data=JSON.parse(re);
                        if(data["state"]==1){
                            swal({
                                title: "完成",
                                text: "成功删除申请",
                                type: "success"

                            },function(){
                                document.getElementById("form_check").submit();
                            })
                        }else{
                            swal({
                                title: "错误",
                                text: data["msg"],
                                type: "warning"
                            });
                        }
                    })
                }
            })
    }
    function hexiao(aid){
        var index = layer.open({
            type:2,
            title:'常规促销申请',
            area:['100%','100%'],
            maxmin:true,
            content:"{:url('TiFeiyong/hexiao')}?aid="+aid
        })
        //location.href="{:url('TiFeiyong/hexiao')}?aid="+aid;
    }
    /*反馈*/
    $(".feedback").click(function () {
        var aid = $(this).attr('aid')
        var aname = $(this).attr('aname')
        /*console.log(aname);
        console.log('aname');*/
        /*if(aname==2){
            var feedback ='<label><input type="radio" name="feedbacktype" value="2" />按系统反馈（按照各系统的产品纬度，反馈活动销量及各费用科目的实际投入情况）</label>';
        }else if (aname==3){
            var feedback ='<label><input type="radio" name="feedbacktype" value="1" />按网点反馈（按照各网点的产品纬度，反馈活动销量及各费用科目的实际投入情况）</label>';
        }else {
            var feedback ='';
        }*/
        var feedback ='<label><input type="radio" name="feedbacktype" value="1" />按网点反馈（按照各网点的产品纬度，反馈活动销量及各费用科目的实际投入情况）</label>';
        var feedback ='';//去掉系统反馈和网点反馈

        var str = '<div method="get" class="form-inline" style="margin:10px">' +
            '<table class="table-bordered table">' +
            '<tr>' +
            '   <th class="info text-center" colspan="2">请选择反馈模式</th>' +
            '   </tr>' +
            '<tr>' +
            '   <td style="min-width:120px;width:120px;" class="text-center">反馈模式<span class="colorRed">*</span></td>' +
            '   <td>' +
            '       <label><input type="radio" name="feedbacktype" value="0" checked />整单反馈（直接反馈活动总销量及各费用科目的实际投入情况）</label><br><br>' +feedback+
            /*'       <label><input type="radio" name="feedbacktype" value="1" />按网点反馈（按照各网点的产品纬度，反馈活动销量及各费用科目的实际投入情况）</label>' +*/
            '   </td>' +
            '</tr>' +
            '</table> ' +
            '<div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">' +
            '   <input type="submit" class="btn btn-success" value="确定" id="feedback">' +
            '   <input type="button" class="btn btn-warning" value="返回" id="cancelBack" style="margin-left:20px"></div></div>'
        layer.open({
            type: 1,
            title: "",
            skin: 'layui-layer-rim', //加上边框
            area: ['800px', '540px'], //宽高
            content: str
        });
        var cancelBack = document.getElementById('cancelBack')
        cancelBack.onclick = function () {
            layer.closeAll();
        }

        $('#feedback').on('click',function () {
            var feedbacktype = $('[name=feedbacktype]:checked').val()
            if(feedbacktype==1){
                location.href="{:url('TiFeiyong/wangdianfankui')}?aid="+aid+'&feedbacktype=1';
            }else if (feedbacktype==2){
                location.href="{:url('TiFeiyong/wangdianfankui')}?aid="+aid+'&feedbacktype=2';
                //location.href="{:url('TiFeiyong/xitongfankui')}?aid="+aid; //系统反馈
            }else{
                location.href="{:url('TiFeiyong/allfankui')}?aid="+aid;
            }


            /*if(feedbacktype==1){
                location.href="{:url('TiFeiyong/wangdianfankui')}?aid="+aid;
            }else{
                location.href="{:url('TiFeiyong/allfankui')}?aid="+aid;
            }*/
            /*if(feedbacktype==1){
                location.href="{:url('TiFeiyongfeedback/wangdianfankuin')}";
            }else{
                location.href="{:url('TiFeiyongfeedback/allfankuin')}";
            }*/
            /*if(feedbacktype==1){
                location.href="{:url('other/wangdianfankuin')}";
            }else{
                location.href="{:url('other/allfankuin')}";
            }*/
        })
        return false
    });

    function yidong(aid){
        location.href="{:url('yidong')}?aid="+aid;
    }

    $("#check").click(function(){

        $(".formpage").submit();
    })
    $("#clear_check").click(function(){
        $("input[type='text']").val("");
        $("#state").val(0);
        $(".formpage").submit();
    })

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY/MM/DD',

        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY/MM/DD',

        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    function gostate(state,apid){
        $.post("{:url('TiFeiyong/gostate')}",{aid:apid,state:state},function(re){
            var data=JSON.parse(re);
            if(data["state"]==1){
                swal({
                    title: "完成",
                    text: "成功提交工作流",
                    type: "success"

                },function(){
                    document.getElementById("form_check").submit();
                })
            }else{
                swal({
                    title: "错误",
                    text: data["msg"],
                    type: "warning"
                });
            }
        })
    }

    function shanchu(apid){
        swal({
                title: "提示",
                text: "您真的要删除这个申请么？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#FF3333",
                confirmButtonText: "是的我要删除",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function (isConfirm) {
                if (isConfirm) {
                    $.post("{:url('TiFeiyong/shanchuap')}",{aid:apid},function(re){
                        var data=JSON.parse(re);
                        if(data["state"]==1){

                            document.getElementById("form_check").submit();

                        }else{
                            alert(data["msg"])
                        }
                    })
                }
            })




    }
    function quxiao(apid){
        location.href="{:url('TiFeiyong/quxiao')}?aid="+apid;

    }
</script>
</body>

</html>
